import React from 'react'
import {
  Redirect
} from 'react-router-dom'


// 使用路由懒加载，到获取这个路由时才加载对应的组件
const HjDiscover = React.lazy(() => import('@/pages/discover'))
const HjAlbum = React.lazy(() => import('@/pages/discover/c-pages/album'))
const HjArtist = React.lazy(() => import('@/pages/discover/c-pages/artist'))
const HjDjradio = React.lazy(() => import('@/pages/discover/c-pages/djradio'))
const HjRanking = React.lazy(() => import('@/pages/discover/c-pages/ranking'))
const HjRecommend = React.lazy(() => import('@/pages/discover/c-pages/recommend'))
const HjSongs = React.lazy(() => import('@/pages/discover/c-pages/songs'))
const HjFriend = React.lazy(() => import('@/pages/friend'))
const HjPlayer = React.lazy(() => import('@/pages/play'))
const HjMine = React.lazy(() => import('@/pages/mine'))

// import HjDiscover from '@/pages/discover'
// import HjAlbum from '@/pages/discover/c-pages/album'
// import HjArtist from '@/pages/discover/c-pages/artist'
// import HjDjradio from '@/pages/discover/c-pages/djradio'
// import HjRanking from '@/pages/discover/c-pages/ranking'
// import HjRecommend from '@/pages/discover/c-pages/recommend'
// import HjSongs from '@/pages/discover/c-pages/songs'
// import HjFriend from '@/pages/friend'
// import HjPlayer from '@/pages/play'
// import HjMine from '@/pages/mine'

const routes = [{
    path: '/',
    exact: true,
    render: () => {
      // 当访问/ 时，就重定向到discover 所以这个函数返回重定向组件
      return <Redirect to = "/discover" / >
    }
  }, {
    path: '/discover',
    component: HjDiscover,
    routes: [{
        path: '/discover',
        exact: true,
        render: () => {
          return <Redirect to = "/discover/recommend" / >
        }
      },
      {
        path: '/discover/recommend',
        component: HjRecommend
      }, {
        path: '/discover/album',
        component: HjAlbum
      }, {
        path: '/discover/artist',
        component: HjArtist
      }, {
        path: '/discover/djradio',
        component: HjDjradio
      }, {
        path: '/discover/ranking',
        component: HjRanking
      }, {
        path: '/discover/songs',
        component: HjSongs
      }, {
        path: '/discover/player',
        component: HjPlayer
      }
    ]
  },
  {
    path: '/friend',
    component: HjFriend
  },
  {
    path: '/mine',
    component: HjMine
  },

]

export default routes